package org.simplecrm.service.event;

import org.simplecrm.domain.event.Event;
import org.simplecrm.repository.event.EventDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by oler on 12.09.14.
 */
@Service
public class EventServiceImpl implements EventService {

    @Autowired
    private EventDAO eventDAO;

    @Override
    @Transactional
    public List<Event> getEventsPage(int customerId, int pageNumber, int pageSize) {

        List res;
        res = eventDAO.getEventsPage(customerId, pageNumber, pageSize);
        return res;
    }

    @Override
    @Transactional
    public Long getEventsCount(int customerId) {

        Long res;
        res = eventDAO.getEventsCount(customerId);
        return res;
    }

    @Override
    @Transactional
    public Event getEventById(int id) {

        Event res;
        res = eventDAO.getEventById(id);
        return res;
    }

    @Override
    @Transactional
    public void deleteEvent(int id) {
        eventDAO.deleteEvent(id);
    }

    @Override
    @Transactional
    public void addNewEvent(Event newEvent) {
        eventDAO.addNewEvent(newEvent);
    }

    @Override
    @Transactional
    public void updateEvent(Event updatedEvent) {
        eventDAO.updateEvent(updatedEvent);
    }
}
